/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.solitaire.web.controller.api;

import com.medusa.gruul.common.core.annotation.EscapeLogin;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.solitaire.api.model.param.manager.SolitaireWeChatBotParam;
import com.medusa.gruul.solitaire.service.manager.ISolitaireWeChatBotService;
import com.medusa.gruul.solitaire.wechat.WeChatBot;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 接龙机器人controller
 * @author lcysike
 * @Date 2020-06-22
 */
@RestController
@RequestMapping("/weChat/boot")
public class SolitaireWeChatBotController {

	@Autowired
	private ISolitaireWeChatBotService solitaireWeChatBotService;

	/**
	 * 机器人登陆
	 */
	@PostMapping("/login")
	@EscapeLogin
	public Result wxLogin(){
		return solitaireWeChatBotService.wxLogin();
	}

	@ApiOperation(value = "检查登陆状态")
	@ApiResponses({@ApiResponse(code = 200, message = "success", response = WeChatBot.class),
			@ApiResponse(code = 400, message = "请登录"), @ApiResponse(code = 201, message = "请扫码"),
			@ApiResponse(code = 202, message = "请在手机上确认登陆")})
	@GetMapping("/checkLogin")
	public Result checkLogin() {
		return solitaireWeChatBotService.checkLogin();
	}


	@ApiOperation(value = "获取群聊列表")
	@GetMapping("/groupList")
	public Result getGroupList(@RequestParam SolitaireWeChatBotParam solitaireWeChatBotParam) {
		return solitaireWeChatBotService.getGroupList(solitaireWeChatBotParam);
	}

	@ApiOperation(value = "搜索群聊")
	@GetMapping("/search")
	public Result searchGroupList(@RequestParam SolitaireWeChatBotParam solitaireWeChatBotParam) {
		return solitaireWeChatBotService.searchGroupList(solitaireWeChatBotParam);
	}

	@ApiOperation(value = "登出")
	@PostMapping("/logout")
	public Result logout() {
		return solitaireWeChatBotService.logout();
	}

	@ApiOperation(value = "删除机器人")
	@DeleteMapping("/remove")
	public Result removeBot(@RequestParam @ApiParam("机器人唯一标识") Long botUin) {
		solitaireWeChatBotService.removeBotByUin(botUin);
		return Result.ok();
	}

}

